import httpUrl from '../etc/config'
const wxget =function (config = {}) {
  const token  = wx.getStorageSync('token')
  config.header={
    'content-type':'application/json',
    'Authorization': 'Bearer ' + token
  }
  config.method = 'GET'
  config.url = httpUrl.basePath + config.url
  wx.request(config);
}
const wxpost =function (config = {}) {
  const token  = wx.getStorageSync('token')
  config.header={
    'content-type':'application/x-www-form-urlencoded',
    'Authorization': 'Bearer ' + token
  }
  config.method = 'POST'
  config.url = httpUrl.basePath + config.url
  wx.request(config);
}
const wxupload =function (config = {}) {
  const token  = wx.getStorageSync('token')
  config.header={
    'content-type':'multipart/form-data',
    'Authorization': 'Bearer ' + token
  }
  config.url = httpUrl.basePath + config.url
  wx.uploadFile(config);
}

module.exports = {
  wxget: wxget,
  wxpost: wxpost,
  wxupload: wxupload
}